package com.liuhan.house.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liuhan.house.dao.AgencyMapper;
import com.liuhan.house.dao.UserMapper;
import com.liuhan.house.pojo.Agency;
import com.liuhan.house.pojo.User;
import com.liuhan.house.service.AgencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgencyImpl implements AgencyService {

    @Autowired
    private AgencyMapper agencyMapper;
    @Autowired
    private UserMapper userMapper;

    /**
     * 查询经纪人详情
     */

    @Override
    public User getAgencyInfoById(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public PageInfo<User> getAgencyNameList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Agency>  agencyList = agencyMapper.selectCompanyName();
        PageInfo pageInfo = new PageInfo(agencyList);
        return pageInfo;
    }

    /**
     * 查询经纪机构名称
     * @return
     */
    @Override
    public List<Agency> selectCompanyName() {
        return agencyMapper.selectCompanyName();
    }


}
